package exercisesI;


import java.text.DecimalFormat;
import java.util.Scanner;

public class Exercise4 {

	/**
	 * @author - Rafael Medina
	 * Ticket vending machine 
	 */
	
	public static void main(String[] args) {
		// Use this to have the price show only two decimals (in case it can show more)
		DecimalFormat TD = new DecimalFormat("#.##"); 
		
		// Declare the scanner variable
		Scanner sc = new Scanner(System.in);		
		
		// Ask the customer's age
		int age;
		System.out.print("Welcome, how old are you? ");
		age = sc.nextInt();
		
		// Now see which price will apply to the customer
		// In this case, it would be better to use if-else instructions due to the age range we have (which would make us have up to 60 cases)
		double price;
		price = 7;
		
		if (age < 5) {
			// 60% discount
			price = price - (price * 0.6);
			System.out.println("Children ticket: " + TD.format(price) + " euros");
		} else if (age > 60) {
			// 55% discount
			
			price = price - (price * 0.55);
			System.out.println("Over 60 ticket: " + TD.format(price) + " euros");
		} else {
			System.out.println("Normal ticket: " + price + " euros");
		}		

	}

}
